package cn.yunhe.pagemybatisplus.controller;
import cn.yunhe.pagemybatisplus.eneity.User;
import cn.yunhe.pagemybatisplus.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserController {

@Resource
private  UserService userService;

    @RequestMapping(value = "/getUsers")
//    public List<User> getSomePerson(@RequestParam(value = "pageNum",defaultValue="1")
//                                                int pageNum )
    public List<User> getSomePerson(int pageNum,int pageSize)
    {
        //pageNum:表示第几页  pageSize:表示一页展示的数据
        PageHelper.startPage(pageNum,pageSize);
        List<User> list1=userService.getList();
        //将查询到的数据封装到PageInfo对象
//        PageInfo<User> pageInfo=new PageInfo(list1,pageSize); 和下面那个都可以
        PageInfo<User> pageInfo=new PageInfo<User>(list1);
        //分割数据成功
        return list1;


}}
